<!DOCTYPE html>
<html>
<head>
  <#import "common/common.macro.ftl" as netCommon>
  <@netCommon.commonStyle />
  <!-- DataTables -->
  <link rel="stylesheet" href="${request.contextPath}/static/adminlte/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
  <title>定时任务管理</title>
</head>
<body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && cookieMap["xxljob_adminlte_settings"]?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if>">
<div class="wrapper">
  <!-- header -->
  <@netCommon.commonHeader />
  <!-- left -->
  <@netCommon.commonLeft "cronjob" />

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>定时任务管理</h1>
    </section>

    </section>
    <!-- Main content -->
    <section class="content">

      <div class="row">
        <!-- 搜索条件区域 -->
        <div class="col-xs-12">
          <div class="box box-primary">
            <div class="box-header with-border">
              <h3 class="box-title">搜索条件</h3>
            </div>
            <div class="box-body">
              <div class="row">
                <!-- IP 地址输入框 -->
                <div class="col-md-3">
                  <div class="form-group">
                    <label for="ipInput">IP地址</label>
                    <input type="text" class="form-control" id="ipInput" placeholder="请输入IP地址">
                  </div>
                </div>

                <!-- 负责人名称输入框 -->
                <div class="col-md-3">
                  <div class="form-group">
                    <label for="personInChargeInput">负责人</label>
                    <input type="text" class="form-control" id="personInChargeInput" placeholder="请输入负责人名称">
                  </div>
                </div>

                <!-- 系统名称输入框 -->
                <div class="col-md-3">
                  <div class="form-group">
                    <label for="systemNameInput">系统名称</label>
                    <input type="text" class="form-control" id="systemNameInput" placeholder="请输入系统名称">
                  </div>
                </div>

                <!-- 服务器用户输入框 -->
                <div class="col-md-3">
                  <div class="form-group">
                    <label for="serverUserInput">服务器用户</label>
                    <input type="text" class="form-control" id="serverUserInput" placeholder="请输入服务器用户">
                  </div>
                </div>
              </div>

              <div class="row">
                <!-- 任务命令模糊查询输入框 -->
                <div class="col-md-3">
                  <div class="form-group">
                    <label for="commandInput">任务命令</label>
                    <input type="text" class="form-control" id="commandInput" placeholder="请输入任务命令（模糊匹配）">
                  </div>
                </div>

                <!-- 每页显示条数选择 -->
                <div class="col-md-3">
                  <div class="form-group">
                    <label for="recordsPerPage">每页显示</label>
                    <select class="form-control" id="recordsPerPage">
                      <option value="10">10</option>
                      <option value="20">20</option>
                      <option value="50">50</option>
                    </select>
                  </div>
                </div>

                <!-- 搜索按钮 -->
                <div class="col-md-2">
                  <div class="form-group">
                    <label>&nbsp;</label>
                    <button class="btn btn-block btn-info" id="searchBtn">搜索</button>
                  </div>
                </div>

                <!-- 新增定时任务按钮 -->
                <div class="col-md-2">
                  <div class="form-group">
                    <label>&nbsp;</label>
                    <button class="btn btn-block btn-success add" type="button" id="addTaskBtn">新增定时任务</button>
                  </div>
                </div>

                <!-- 定时任务初始化按钮 -->
                <div class="col-md-2">
                  <div class="form-group">
                    <label>&nbsp;</label>
                    <button class="btn btn-block btn-primary add" type="button" id="initTaskBtn">定时任务初始化</button>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 批量操作按钮区域 -->
      <div class="row" style="margin-top: 10px;">
        <div class="col-xs-12" style="display: flex; align-items: center;">
          <div style="display: flex; align-items: center; margin-right: 20px;">
            <input type="checkbox" id="selectAll" style="margin-right: 10px;">
            <label for="selectAll" style="margin: 0;">全选</label>
          </div>
          <button id="bulkDisableBtn" class="btn btn-danger" style="margin-right: 10px; width: 120px;">批量注释</button>
          <button id="bulkEnableBtn" class="btn btn-success" style="width: 120px;">批量启用</button>
        </div>
      </div>


      <!-- 数据表格 -->
      <div class="row">
        <div class="col-xs-12">
          <div class="box">
            <div class="box-body">
              <table id="cronjob_list" class="table table-bordered table-striped" width="100%">
                <thead>
                <tr>
                  <th>选择</th> <!-- 添加任务的选择列 -->
                  <th>IP 地址</th>
                  <th>负责人</th>
                  <th>系统名称</th>
                  <th>调度时间</th>
                  <th>任务命令</th>
                  <th>服务器用户</th>
                  <th>状态</th>
                  <th>更新时间</th>
                  <th>操作</th>
                </tr>
                </thead>
                <tbody></tbody>
                <tfoot></tfoot>
              </table>
            </div>
          </div>
        </div>
      </div>

      <!-- 分页控件 -->
      <div class="row">
        <div class="col-xs-12 text-center">
          <div id="pagination"></div>
        </div>
      </div>

    </section>
  </div>

  <!-- footer -->
  <@netCommon.commonFooter />
</div>


<!-- 编辑任务模态框 -->
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title">编辑定时任务</h4>
      </div>
      <div class="modal-body">
        <form class="form-horizontal form" role="form">
          <div class="form-group">
            <label for="editJobId" class="col-sm-2 control-label">任务ID</label>
            <div class="col-sm-8"><input type="text" class="form-control" id="editJobId" disabled></div>
          </div>

          <div class="form-group">
            <label for="editOwner" class="col-sm-2 control-label">负责人<font color="red">*</font></label>
            <div class="col-sm-8"><input type="text" class="form-control" id="editOwner" placeholder="请输入负责人"></div>
          </div>

          <div class="form-group">
            <label for="editSystemName" class="col-sm-2 control-label">系统名称<font color="red">*</font></label>
            <div class="col-sm-8"><input type="text" class="form-control" id="editSystemName" placeholder="请输入系统名称"></div>
          </div>

          <div class="form-group">
            <label for="editSchedule" class="col-sm-2 control-label">调度时间<font color="red">*</font></label>
            <div class="col-sm-8">
              <input type="text" class="form-control" id="editSchedule" placeholder="请输入调度时间 (* * * * *)">
              <small class="form-text text-muted">
                调度时间格式：* * * * *：分钟、小时、日期、月份、星期几<br>
              </small>
            </div>
          </div>

          <div class="form-group">
            <label for="editCommand" class="col-sm-2 control-label">任务命令<font color="red">*</font></label>
            <div class="col-sm-8">
              <textarea class="form-control" id="editCommand" rows="4" placeholder="请输入任务命令"></textarea>
            </div>
          </div>

          <div class="form-group">
            <label for="editIp" class="col-sm-2 control-label">IP地址</label>
            <div class="col-sm-8"><input type="text" class="form-control" id="editIp" disabled></div>
          </div>

          <div class="form-group">
            <label for="editServerUser" class="col-sm-2 control-label">服务器用户</label>
            <div class="col-sm-8"><input type="text" class="form-control" id="editServerUser" disabled></div>
          </div>

          <!-- 新增：任务状态和上次修改时间 -->
          <div class="form-group">
            <label for="editStatus" class="col-sm-2 control-label">任务状态</label>
            <div class="col-sm-8"><input type="text" class="form-control" id="editStatus" disabled></div>
          </div>

          <div class="form-group">
            <label for="editUptime" class="col-sm-2 control-label">上次修改时间</label>
            <div class="col-sm-8"><input type="text" class="form-control" id="editUptime" disabled></div>
          </div>

          <hr>
          <div class="form-group">
            <div class="col-sm-offset-3 col-sm-6">
              <button class="btn btn-primary" id="saveBtn">保存</button>
              <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>

<!-- 编辑后的保存任务模态框 -->
<div class="modal fade" id="saveModal" tabindex="-1" role="dialog" aria-labelledby="saveModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title" id="saveModalLabel">二次认证</h4>
      </div>
      <div class="modal-body">
        <form>
          <div class="form-group">
            <label for="verifyUserSecondary">用户</label>
            <input type="text" class="form-control" id="verifyUserSecondary" placeholder="请输入二次认证用户">
          </div>
          <div class="form-group">
            <label for="verifyPasswordSecondary">密码</label>
            <input type="password" class="form-control" id="verifyPasswordSecondary" placeholder="请输入密码">
          </div>
          <div class="form-group">
            <label for="ticketNumber">工单号</label>
            <input type="text" class="form-control" id="ticketNumber" placeholder="请输入工单号">
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button type="button" class="btn btn-primary" id="saveTaskBtn">保存</button>
      </div>
    </div>
  </div>
</div>

<!-- 新增定时任务模态框 -->
<div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title">新增定时任务</h4>
      </div>
      <div class="modal-body">
        <form class="form-horizontal" id="addCronJobForm">
          <div class="form-group">
            <label for="addIp" class="col-sm-3 control-label">IP 地址</label>
            <div class="col-sm-8"><input type="text" class="form-control" id="addIp" placeholder="请输入 IP 地址"></div>
          </div>
          <div class="form-group">
            <label for="addOwner" class="col-sm-3 control-label">负责人</label>
            <div class="col-sm-8"><input type="text" class="form-control" id="addOwner" placeholder="请输入负责人"></div>
          </div>
          <div class="form-group">
            <label for="addSystemName" class="col-sm-3 control-label">系统名称</label>
            <div class="col-sm-8"><input type="text" class="form-control" id="addSystemName" placeholder="请输入系统名称"></div>
          </div>
          <div class="form-group">
            <label for="addServerUser" class="col-sm-3 control-label">服务器用户</label>
            <div class="col-sm-8"><input type="text" class="form-control" id="addServerUser" placeholder="请输入服务器用户如root、mysql等"></div>
          </div>
          <div class="form-group">
            <label for="addSchedule" class="col-sm-3 control-label">调度时间</label>
            <div class="col-sm-8"><input type="text" class="form-control" id="addSchedule" placeholder="请输入调度时间"></div>
          </div>
          <div class="form-group">
            <label for="addCommand" class="col-sm-3 control-label">任务命令</label>
            <div class="col-sm-8"><input type="text" class="form-control" id="addCommand" placeholder="请输入任务命令"></div>
          </div>
          <div class="form-group">
            <label for="addStatus" class="col-sm-3 control-label">状态</label>
            <div class="col-sm-8"><input type="text" class="form-control" id="addStatus" value="生效" readonly></div>
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-primary" id="saveNewTaskBtn">保存</button>
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
      </div>
    </div>
  </div>
</div>

<@netCommon.commonScript />
<script src="${request.contextPath}/static/adminlte/bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="${request.contextPath}/static/adminlte/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<script src="${request.contextPath}/static/js/crontab.js"></script>
</body>
</html>
